import http from '@/utils/request.js'

/**
 * 获取新闻频道推荐
 * @param {*} channelId
 * @param {*} timestamp 时间戳，请求新的推荐数据传当前的时间戳，请求历史推荐传指定的时间戳
 */

export const reqGetArticles = (channelId, timestamp) => {
  return http({
    method: 'get',
    url: '/app/v1_1/articles',
    params: {
      channel_id: channelId,
      timestamp,
      with_top: 1
    }
  })
}

/***
 * 不喜欢请求
 */
export const reqDisLikeArticle = (articleId) => {
  return http({
    method: 'post',
    url: '/app/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}
/**
 * 举报文章请求
 * @param {} articleId
 * @param {*} type
 */
export const reqReportArticle = (articleId, type) => {
  return http({
    method: 'post',
    url: '/app/v1_0/article/reports',
    data: {
      target: articleId,
      type
    }
  })
}

/**
 * 获取文章详情
 * @param {*} articleId
 */
export const reqGetArticleDetail = (articleId) => {
  return http({
    method: 'get',
    url: `/app/v1_0/articles/${articleId}`
  })
}

/**
 * 点赞
 * @param {*} articleId
 */
export const reqAddLike = (articleId) => {
  return http({
    method: 'post',
    url: '/app/v1_0/article/likings',
    data: {
      target: articleId
    }
  })
}

/**
 * 取消点赞
 * @param {*} articleId
 */
export const reqDeleteLike = (articleId) => {
  return http({
    method: 'delete',
    url: '/app/v1_0/article/likings/' + articleId
  })
}
/**
 * 取消文章不喜欢
 * @param {*} target
 */
export const reqDeleteDislike = (target) => {
  return http({
    method: 'delete',
    url: '/app/v1_0/article/dislikes/' + target

  })
}
/**
 * 添加文章不喜欢
 * @param {*} target
 */
export const reqAddDislike = (target) => {
  return http({
    method: 'post',
    url: '/app/v1_0/article/dislikes',
    data: {
      target
    }
  })
}
